package dgo.interval;
public class IntervalRunner {
  private Interval _interval;
  private boolean _done;
  private IntervalNode _node;
  
 public IntervalRunner(){
  reset();
}
   
  public IntervalRunner(Interval interval){
    _interval = interval;
    _done = false;
    reset();
  }
  
  public void clear(){
    //
  }
  
  public boolean isDone(){
    return _done;
  }

  public void reset(){
    if(_interval != null){
      _node = new IntervalNode(_interval);
      _done = false;
    }else{
      _done = true;
    }
  }
  
  public void setInterval(Interval interval){
    _interval = interval;
    this.reset();
  }
        
  public boolean update(){
    if(_interval == null) return true;
    if(!_done && !_interval.call(_node)) _done = true;
    return _done;
  }
}